package com.basic.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

/**
 * @Description:
 * @Date: 2024-03-28 09:04
 * @Author: wz
 **/
public class UdpReceiver {

    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(9099);
        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes,0,bytes.length);
        socket.receive(dp);
        System.out.println(new String(dp.getData(),0,dp.getLength()));
//        socket.disconnect();
        socket.close();
    }
}
